﻿using System;
using System.Diagnostics.CodeAnalysis;

namespace Bookvar.ApplicationModel
{
    /// <summary>
    /// Interface for the BookvarServiceProvider class.
    /// </summary>
    public interface IBookvarServiceProvider : IServiceProvider
    {
        void RemoveService( Type serviceType );

        [SuppressMessage( "Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter" )]
        void RemoveService<T>() where T : class;

        /// <summary>
        /// Removes a service by its name. If there is no such service registered with this name, nothing happens.
        /// </summary>
        /// <typeparam name="T">The type of the service.</typeparam>
        /// <param name="name">The name of the service to remove.
        /// This name should be the same as the one with which the service has been registered.</param>
        [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        void RemoveService<T>(string name) where T : class;

        void AddService( Type serviceType, object service );

        void AddService<T>( T service ) where T : class;

        void AddService<T>( T service, string name ) where T : class;

        /// <summary>
        /// Retrieves a service with the selected type. If the service is not found <a>null</a> is returned.
        /// </summary>
        /// <typeparam name="T">Type of the service to retrieve.</typeparam>
        /// <returns>
        /// null if the service with the selected file is not found; 
        /// otherwise the service for the selected type is returned
        /// </returns>
        [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        T GetService<T>() where T : class;

        /// <summary>
        /// Retrieves a service with the selected type by its name. If the service is not found <a>null</a> is returned.
        /// </summary>
        /// <typeparam name="T">Type of the service to retrieve.</typeparam>
        /// <returns>
        /// null if the service with the selected file is not found; 
        /// otherwise the service for the selected type is returned
        /// </returns>
        [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
        T GetService<T>(string name) where T : class;
    }
}
